<template>
	<view class="page-wrap" :data-theme="theme" :class="theme" :style="globalColor.style">
		<HeadCustom title="邀约记录" :isAppBtn="false"></HeadCustom>
		<view class="card-box">
			<view class="card-hd">
				<SearchCustom :keyword.sync="keyword" @search="getInit()" />
			</view>
			<view class="card-bd fboxCol Ycenter Xcenter">
				<view v-if="listConfig.loading == 'list-not'">
					<NotEmpty :height="scrollHeight" />
				</view>
				<view v-if="listData.length || listConfig.loading =='loading'">
					<scroll-view :scroll-top="scrollTop" scroll-y="true" 
					:style="{height: scrollHeight +'px'}"
					@scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
						<view class="card-scroll">
						<view v-for="(item, index) in listData" :key="index">
							<VitaItem type="invitationRecord" :innerData="item" />
						</view>
						<u-loadmore fontSize="24rpx" :status="listConfig.loading" />
						</view>
					</scroll-view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {orgInvitationRecord} from '@/api/recruit.js';
	import VitaItem from '../components/vita-item.vue';
	import NavFilter from '../components/nav-filter.vue';
	import SearchCustom from '@/components/search/search-custom.vue';
	import {listMixins} from '../common/list.mixins.js';
	export default {
		mixins: [listMixins],
		components:{VitaItem,NavFilter,SearchCustom},
		data() {
			return {
				theme: getApp().globalData.appTheme,
						globalColor: getApp().globalData.globalColor,
				scrollTop: 0,
				listConfig: {
					current: 1,
					size: 20,
					count: 0,
					loading: 'loading'
				},
				listData: [],
				keyword: '',
				companyId: getApp().globalData.companyId,
				scrollHeight: 0
			}
		},
		onLoad() {
			this.getInit()
		},
		onReady() {
			this.getHeight('.head-custom-wrap, .search-wrap')
		},
		methods: {
			getInit(){
				this.listConfig = {
					current: 1,
					size: 20,
					count: 0,
					loading: 'loading'
				}
				this.listData = []
				this.getList()
			},
			getList(){
				const { current, size, loading} = this.listConfig
				const {keyword, companyId} = this
				orgInvitationRecord({current, size,keyword, companyId}).then(res=>{
					if(this.listData.length){
						this.listData = this.listData.concat(res.data.list) 
					}else{
						this.listData = res.data.list
					}
					this.listLoading(res)
				})
			},
			upper(e) {
				console.log('upper',e)
			},
			lower(e) {
				console.log('lower',e)
				this.listMore()
			},
			scroll(e) {
				this.scrollTop = e.detail.scrollTop
			},
			goTop(e) {
				// 解决view层不同步的问题
				this.scrollTop = this.old.scrollTop
				this.$nextTick(function() {
					this.scrollTop = 0
				});
				uni.showToast({
					icon: "none",
					title: "纵向滚动 scrollTop 值已被修改为 0"
				})
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.page-wrap{min-height: calc(100vh);}	
	.card-box .card-hd{}
	.card-scroll{padding:24rpx;}
</style>
